package com.seal.yoyoshop.service.impl;

import com.seal.yoyoshop.bin.Type;
import com.seal.yoyoshop.dao.TypeDao;
import com.seal.yoyoshop.dao.impl.TypeDaoImpl;
import com.seal.yoyoshop.service.TypeService;

import java.util.List;

public class TypeServiceImpl implements TypeService {
    TypeDao typeDao = new TypeDaoImpl();

    @Override
    public List<Type> getTypeList() {
        List<Type> typeList = typeDao.selectTypeList();
        return typeList;
    }

    @Override
    public Type getTypeById(int id) {
        Type type = typeDao.selectTypeById(id);
        return type;
    }

    @Override
    public boolean addType(Type type) {
        boolean isSuccess = typeDao.insertType(type);
        return isSuccess;
    }

    @Override
    public boolean updateTypeByType(Type type) {
        boolean isSuccess = typeDao.updateType(type);
        return isSuccess;
    }

    @Override
    public boolean deleteType(Type type) {
        type.setStatus(0);
        boolean isSuccess = typeDao.updateType(type);
        return isSuccess;
    }
}
